xen/sched: fix cpu hotplug
authorJuergen Gross <jgross@suse.com>
Mon, 5 Sep 2022 07:00:05 +0000 (09:00 +0200)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 5 Sep 2022 10:42:30 +0000 (11:42 +0100)
commitd84473689611eed32fd90b27e614f28af767fa3f
tree51bbcdb6c6bec82e5bdb2f72ac02f9c693db3650
parentd42be6f83480b3ada286dc18444331a816be88a3
xen/sched: fix cpu hotplug

Cpu unplugging is calling schedule_cpu_rm() via stop_machine_run() with
interrupts disabled, thus any memory allocation or freeing must be
avoided.

Since commit 5047cd1d5dea ("xen/common: Use enhanced
ASSERT_ALLOC_CONTEXT in xmalloc()") this restriction is being enforced
via an assertion, which will now fail.

Fix this by allocating needed memory before entering stop_machine_run()
and freeing any memory only after having finished stop_machine_run().

Fixes: 1ec410112cdd ("xen/sched: support differing granularity in schedule_cpu_[add/rm]()")
Reported-by: Gao Ruifeng <ruifeng.gao@intel.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/sched/core.c
xen/common/sched/cpupool.c
xen/common/sched/private.h